var o, e = require, t = module, n = exports, i = this && this.__extends || (o = function(e, t) {
    return (o = Object.setPrototypeOf || {
        __proto__: []
    } instanceof Array && function(e, t) {
        e.__proto__ = t;
    } || function(e, t) {
        for (var o in t) t.hasOwnProperty(o) && (e[o] = t[o]);
    })(e, t);
}, function(e, t) {
    function i() {
        this.constructor = e;
    }
    o(e, t), e.prototype = null === t ? Object.create(t) : (i.prototype = t.prototype, 
    new i());
}), a = this && this.__decorate || function(e, t, o, i) {
    var n, a = arguments.length, s = a < 3 ? t : null === i ? i = Object.getOwnPropertyDescriptor(t, o) : i;
    if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) s = Reflect.decorate(e, t, o, i); else for (var l = e.length - 1; 0 <= l; l--) (n = e[l]) && (s = (a < 3 ? n(s) : 3 < a ? n(t, o, s) : n(t, o)) || s);
    return 3 < a && s && Object.defineProperty(t, o, s), s;
};

Object.defineProperty(n, "__esModule", {
    value: !0
});

var r = e("JoystickCommon"), s = e("Player"), c = e("PlayerModel"), l = e("Global"), d = e("AudioManager"), u = e("GameManager"), p = e("ArmView"), h = e("PetManager"), f = e("GameConfig"), g = e("GameData"), m = e("LoadManager"), y = cc._decorator, v = y.ccclass, w = y.property, b = function(o) {
    function e() {
        var e = null !== o && o.apply(this, arguments) || this;
        return e.player = null, e.gameView = null, e.bar = null, e.label = null, e.isStart = !1, 
        e.path_idx = 0, e.path = [], e.delay = 1, e.think = 1, e.findTime = 0, e.intervalTime = .1, 
        e.continueTime = 4, e.petIdx = 0, e.form = 0, e.config = null, e.scale = .4, e.skill = null, 
        e.IDLE = e.model.IDLE, e;
    }
    var n;
    return i(e, o), (n = e).prototype.onLoad = function() {
        this.skeleton.node.scale = this.scale;
    }, e.prototype.onDisable = function() {
        this.bottomNode && this.bottomNode.active && (this.bottomNode.active = !1);
    }, e.prototype.start = function() {
        this.loadSkin(this.petIdx);
    }, e.prototype.initPet = function(e, t) {
        var o = this;
        this.gameView = u.default.getInstance().gameView, this.gameView.targets.push(this), 
        this.loadModel(e, t), this.load(), this.hpView.init(this.model.MAX_HP), this.hpView.refresh(this.model.HP), 
        this.bar.fillRange = 1, this.entrance(), this.schedule(function() {
            var e;
            o.isStart && !o.isPlay && o.checkTarget(o.player) && (o.model.hasBuffer(c.BufferType.切割) || (o.canAttack() ? 0 < (e = o.findTargets()).length ? (o.target = e[0], 
            o.run(e[0])) : (o.target = null, o.run(o.player)) : o.run(o.player)));
        }, this.think);
    }, e.prototype.loadModel = function(e, t) {
        this.petIdx = t.id + t.form, this.form = t.form, this.player = e, this.model.openid = e.model.openid, 
        this.model.group = e.model.group;
        var o = h.default.getInstance().getPetDataIdx(this.petIdx), e = isNaN(t.lv) ? 1 < t.form ? GA.rand(l.G.petEvolve[t.form - 1], l.G.petEvolve[t.form]) : GA.rand(0, l.G.petEvolve[0]) : Math.min(t.lv, l.G.petEvolve[t.form]);
        this.config = h.default.getInstance().getConfig(o), this.model.RAN = this.config.RAN, 
        this.model.ATK = h.default.getInstance().getAtk(o, e), u.default.getInstance().matchType == u.MatchType.三对三 && (this.model.ATK = this.model.ATK_ORG = this.model.ATK / 2), 
        this.model.IDLE = h.default.getInstance().getIdle(o, e), this.model.MAX_HP = h.default.getInstance().getHp(o, e), 
        console.log("ai pet level", e, this.model.MAX_HP), this.model.openid == GA.Info.openId ? this.model.HP = isNaN(t.hp) ? h.default.getInstance().getRealHp(o) : t.hp : this.model.HP = Math.floor(this.model.MAX_HP * (.3 * Math.random() + .7));
    }, e.prototype.loadSkin = function(i) {
        var n = this;
        return void 0 === i && (i = h.default.getInstance().getPetIdx()), new Promise(function(t, o) {
            m.default.getInstance().loadRes({
                url: "skin/p" + i + "/" + h.default.getInstance().getSkinConfig(Math.round(i / 100)).suf,
                type: sp.SkeletonData
            }).then(function(e) {
                n.skeleton && e instanceof sp.SkeletonData && (n.skeleton.skeletonData = e, 100 <= i && (n.hpView.node.y = 100, 
                n.label && (n.label.node.y = 120)), n.changeAnimation({
                    animation: "move2",
                    loop: !0
                })), t();
            }).catch(function(e) {
                console.error(e), o();
            });
        });
    }, e.prototype.move = function() {
        var e;
        this.player && this.player.checkTarget(this.player) && (e = this.moveDir.mul(this._moveSpeed / 60).add(this.offect.mul(1 / 60)), 
        (e = this.node.getPosition().add(e)).equals(this.node.getPosition()) ? this.checkPlayerDistance() : (this.node.setPosition(this.check(e)), 
        this.node.zIndex = 2 * -Math.floor((this.node.y + this.gameView.map.height / 2) / 80) + 1));
    }, e.prototype.run = function(e) {
        var t = this;
        this.checkTarget(e) && (this.model.hasBuffer(c.BufferType.切割) && this.target ? this.model.openid == GA.Info.openId && cc.log("宠物追踪目标") : this.model.hasBuffer(c.BufferType.停顿) ? this.model.openid == GA.Info.openId && cc.log("宠物等待") : this.model.hasBuffer(c.BufferType.移动) && this.findTime + 2e3 < Date.now() ? this.model.openid == GA.Info.openId && cc.log("宠物移动中") : (this.model.openid == GA.Info.openId && cc.log("宠物移动"), 
        this.findPath(e), 1 < this.path.length ? (this.path_idx = this.path.length - 2, 
        this.model.addBuffer(c.BufferType.移动), this.doRun()) : (this.model.addBuffer(c.BufferType.移动), 
        this.scheduleOnce(function() {
            t.model.removeBuffer(c.BufferType.移动);
        }, this.delay))));
    }, e.prototype.doRun = function() {
        var e, t = this;
        -1 < this.path_idx && this.path_idx < this.path.length && (!this.canMove() || this.isPlay ? this.scheduleOnce(function() {
            t.doRun();
        }, this.delay) : (e = this.gameView.astar.getPos(this.path[this.path_idx]).sub(this.node.getPosition()), 
        this.moveDir = e.normalize(), this._speedType = r.default.SpeedType.NORMAL, this.scheduleOnce(function() {
            t.path_idx--, t.path_idx < 0 ? t.model.removeBuffer(c.BufferType.移动) : t.doRun();
        }, Math.ceil(e.mag()) / 200)));
    }, e.prototype.attack = function() {
        this.model.hasBuffer(c.BufferType.冷却) ? this.model.openid == GA.Info.openId && cc.log("宠物攻击冷却中") : this.doAttack(this.target);
    }, e.prototype.attackEnd = function(e) {
        var t = this;
        void 0 === e && (e = this.model.IDLE), this.target = null, 0 < e ? (this.model.hasBuffer(c.BufferType.冷却) || (this.bar.fillRange = 0, 
        this.IDLE = e, this.model.addBuffer(c.BufferType.冷却)), this.scheduleOnce(function() {
            t.model.removeBuffer(c.BufferType.冷却);
        }, e)) : (this.bar.fillRange = 1, this.model.removeBuffer(c.BufferType.冷却));
    }, e.prototype.doAttack = function(e) {
        if (!this.checkTarget(e)) return !1;
        if (e instanceof s.default) {
            switch (this.skill.id) {
              case 0:
                this.attackOne(e), this.attackEnd();
                break;

              case 1:
                this.attackTwo(e), this.attackEnd();
                break;

              case 2:
                this.attackThree();
                break;

              case 3:
                this.attackFour(e), this.attackEnd();
                break;

              case 4:
                this.attackFive(e);
                break;

              case 5:
                this.attackSix();
                break;

              case 6:
                this.attackSeven(e), this.attackEnd();
                break;

              case 7:
                this.attackAngleOne();
                break;

              case 8:
              case 9:
                this.attackSeven(e), this.attackEnd();
                break;

              default:
                this.attackOne(e), this.attackEnd();
            }
            return !0;
        }
        return !1;
    }, e.prototype.attackOne = function(t) {
        var o = this;
        this.model.addBuffer(c.BufferType.执行), this.pauseMove();
        var i = this.getSkill(0);
        this.changeAnimation({
            animation: "attack",
            loop: !1,
            callback: function() {
                var e;
                o.canDoAttack() ? (e = t.node.position.add(o.node.position.sub(t.node.position).normalize().mul(40)), 
                cc.tween(o.node).to(.1, {
                    position: e
                }).call(function() {
                    o.node.zIndex = 2 * -Math.floor((o.node.y + o.gameView.map.height / 2) / 80) + 1;
                }).start(), o.skeleton.timeScale = 3, d.default.getInstance().playAudio("闪电枪"), 
                o.changeAnimation({
                    animation: "attack2",
                    loop: !1,
                    callback: function() {
                        var e;
                        o.model.removeBuffer(c.BufferType.执行), o.canMove() && o.resumeMove(), t.model.isDead() || ((e = new c.default()).group = o.model.group, 
                        e.ATK = o.model.ATK * i.scale, e.CRI = 0, e.type = c.ArmType.闪电枪, t.doHurt(e)), 
                        o.skill = null;
                    }
                })) : (o.model.removeBuffer(c.BufferType.执行), o.canMove() && o.resumeMove(), o.skill = null);
            }
        });
    }, e.prototype.attackTwo = function(o) {
        var i = this;
        this.model.addBuffer(c.BufferType.执行), this.pauseMove();
        var n = this.getSkill(1);
        this.changeAnimation({
            animation: "attack",
            loop: !1,
            callback: function() {
                i.model.removeBuffer(c.BufferType.执行), i.canMove() && i.resumeMove(), i.model.MOV = 800, 
                i.model.pow = 300, i.model.bullet = 30, i.model.type = c.ArmType.导弹枪;
                var t = 0;
                i.schedule(function() {
                    var e;
                    i.canDoAttack() && (d.default.getInstance().playAudio("狙击枪", 1), (e = i.gameView.getArm().getComponent(p.default)) && (e.node.setParent(i.gameView.bulletLayout), 
                    e.node.setPosition(i.node.getPosition().add(i.getOffect())), e.init(i, cc.instantiate(i.model), i.getDir(o), i.node.getPosition().add(i.getOffect())), 
                    e.model.ATK = Math.round(e.model.ATK * n.scale), e.radius = n.radius, i.offect = i.getDir(o).mul(2 * -i.model.pow))), 
                    t++, n.num == t && (i.skill = null);
                }, .2, n.num - 1, 0);
            }
        });
    }, e.prototype.attackThree = function() {
        var e = this;
        this.target && !this.model.hasBuffer(c.BufferType.切割) && (this.model.openid == GA.Info.openId && cc.log("宠物开始攻击3"), 
        this.bar.fillRange = 0, this.IDLE = .6 + this.continueTime + this.model.IDLE, this.model.addBuffer(c.BufferType.冷却), 
        this.model.addBuffer(c.BufferType.切割), this.model.addBuffer(c.BufferType.执行), this.pauseMove(), 
        this.changeAnimation({
            animation: "attack3",
            loop: !1,
            callback: function() {
                e.model.removeBuffer(c.BufferType.执行), e.canMove() && e.resumeMove(), e.schedule(e.attackThreeDo, e.intervalTime, Math.floor(e.continueTime / e.intervalTime) - 1, 0), 
                e.scheduleOnce(e.attackThreeEnd, e.continueTime);
            }
        }));
    }, e.prototype.attackThreeDo = function() {
        var t = this;
        this.model.openid == GA.Info.openId && cc.log("宠物执行攻击3");
        var o, i = this.getSkill(2);
        this.canDoAttack() && this.checkTarget(this) && ((o = new c.default()).group = this.model.group, 
        o.ATK = Math.round(this.model.ATK * i.scale), o.CRI = 20, o.type = c.ArmType.切割, 
        this.gameView.astar.retrieve(cc.rect(this.node.x - i.radius, this.node.y - i.radius / 2, 2 * i.radius, i.radius)).forEach(function(e) {
            e.isCanAttacked(o.type) && e.node.position.sub(t.node.position).mag() <= i.radius && e.doHurt(o);
        }), this.gameView.targets.forEach(function(e) {
            t.checkTarget(e) && e.canHurt() && e.model.group != t.model.group && e.node.position.sub(t.node.position).mag() < i.radius && e.doHurt(o);
        }));
    }, e.prototype.attackThreeEnd = function() {
        this.model.openid == GA.Info.openId && cc.log("宠物攻击3结束"), this.model.removeBuffer(c.BufferType.切割), 
        this.model.removeBuffer(c.BufferType.移动), this.checkPlayerDistance(), this.unschedule(this.attackThreeDo), 
        this.attackEnd(), this.skill = null;
    }, e.prototype.attackFour = function(t) {
        var o = this;
        this.model.addBuffer(c.BufferType.执行), this.pauseMove(), this.model.MOV = 800, this.model.pow = 300, 
        this.model.bullet = 30, this.model.type = c.ArmType.火球;
        var i = this.getSkill(3);
        this.changeAnimation({
            animation: "attack",
            loop: !1,
            event: function() {
                d.default.getInstance().playAudio("宠物龙喷火攻击", 1);
                var e = o.gameView.getArm().getComponent(p.default);
                e && (e.node.setParent(o.gameView.bulletLayout), e.node.setPosition(o.node.getPosition().add(o.getOffect())), 
                e.init(o, cc.instantiate(o.model), o.getDir(t).rotate(cc.misc.degreesToRadians(20 * (Math.random() - .5))), o.node.getPosition().add(o.getOffect())), 
                e.model.ATK = Math.round(e.model.ATK * i.scale), e.radius = i.radius, o.offect = o.getDir(t).mul(2 * -o.model.pow));
            },
            callback: function() {
                o.skeleton.setEventListener(null), o.model.removeBuffer(c.BufferType.执行), o.canMove() && o.resumeMove(), 
                o.skill = null;
            }
        });
    }, e.prototype.attackFive = function(e) {
        var o = this;
        this.pauseMove(!0), this.hpView.node.active = !1, this.bar.fillRange = 0;
        var i = this.getSkill(4);
        this.IDLE = 3 + this.model.IDLE, this.model.addBuffer(c.BufferType.无敌), this.model.addBuffer(c.BufferType.冷却), 
        this.model.addBuffer(c.BufferType.执行), d.default.getInstance().playAudio("宠物龙起飞"), 
        this.changeAnimation({
            animation: "attack1",
            loop: !1,
            flag: !0,
            callback: function() {
                o.skeleton.node.active = !1, o.node.setPosition(e.node.getPosition()), o.node.zIndex = 2 * -Math.floor((o.node.y + o.gameView.map.height / 2) / 80) + 1, 
                o.gameView.appendSkeleton({
                    url: "skeleton/瞄准/miaozhun",
                    root: o.node.parent,
                    pos: e.node.getPosition().sub(cc.v2(120, 0))
                }).then(function(e) {
                    e.node.zIndex = -100, e.node.scale = 1.3, e.node.active = !0, e.timeScale = 2, e.setAnimation(0, "miaozhun", !1), 
                    e.setCompleteListener(function() {
                        cc.tween(e.node).to(.5, {
                            opacity: 0
                        }).call(function() {
                            o.gameView.removeSkeleton(e.node);
                        }).start();
                    });
                }), o.scheduleOnce(function() {
                    o.skeleton.node.active = !0, o.hpView.node.active = !0, d.default.getInstance().playAudio("宠物龙落地攻击", 10), 
                    o.changeAnimation({
                        animation: "attack2",
                        loop: !1,
                        flag: !0,
                        event: function() {
                            var t = new c.default();
                            t.group = o.model.group, t.ATK = Math.round(o.model.ATK * i.scale), t.type = c.ArmType.正常, 
                            o.gameView.astar.retrieve(cc.rect(o.node.x - i.radius, o.node.y - i.radius, 2 * i.radius, 2 * i.radius)).forEach(function(e) {
                                e.isCanAttacked(t.type) && e.node.position.sub(o.node.position).mag() <= i.radius && e.doHurt(t);
                            }), o.gameView.targets.forEach(function(e) {
                                o.checkTarget(e) && e.canHurt() && e.model.group != o.model.group && e.node.position.sub(o.node.position).mag() < i.radius && (e.doHurt(t), 
                                e.doBlow(function() {
                                    e instanceof n && e.model.hasBuffer(c.BufferType.切割) || e.attackEnd(0);
                                }));
                            }), l.G.shakeEffect(u.default.getInstance().gameView.map, .08);
                        },
                        callback: function() {
                            o.model.removeBuffer(c.BufferType.无敌), o.model.removeBuffer(c.BufferType.执行), o.canMove() && o.resumeMove(!0), 
                            o.attackEnd(), o.skill = null;
                        }
                    });
                }, 1);
            }
        });
    }, e.prototype.attackSix = function() {
        var o = this;
        this.pauseMove(!0), this.model.pow = 50, this.model.type = c.ArmType.落雷, this.model.addBuffer(c.BufferType.冷却), 
        this.model.addBuffer(c.BufferType.执行), this.bar.fillRange = 0;
        var i = this.getSkill(5);
        this.IDLE = 2 + .1 * i.num + this.model.IDLE, this.changeAnimation({
            animation: "attack4",
            loop: !1,
            flag: !0,
            callback: function() {
                o.changeAnimation({
                    animation: "attack5",
                    loop: !1,
                    flag: !0,
                    callback: function() {
                        o.changeAnimation({
                            animation: "attack6",
                            loop: !0,
                            flag: !0
                        });
                        var t = 0;
                        o.schedule(function() {
                            var e = o.gameView.getArm().getComponent(p.default);
                            e && (e.node.setParent(o.gameView.bulletLayout), e.node.setPosition(o.node.getPosition().add(cc.v2(GA.rand(-i.radius, i.radius), GA.rand(-i.radius, i.radius)))), 
                            e.init(o, cc.instantiate(o.model), cc.Vec2.ZERO, o.node.getPosition().add(cc.v2(GA.rand(-i.radius, i.radius), GA.rand(-i.radius, i.radius)))), 
                            e.model.ATK = Math.round(e.model.ATK * i.scale), e.radius = i.radius), t++, i.num == t && (o.skill = null);
                        }, .1, i.num - 1, 0), o.scheduleOnce(function() {
                            o.changeAnimation({
                                animation: "attack7",
                                loop: !1,
                                flag: !0,
                                callback: function() {
                                    o.model.removeBuffer(c.BufferType.执行), o.canMove() && o.resumeMove(!0), o.attackEnd();
                                }
                            });
                        }, .1 * i.num);
                    }
                });
            }
        });
    }, e.prototype.attackSeven = function(e) {
        var t = this;
        this.model.addBuffer(c.BufferType.执行), this.pauseMove(!0);
        var o = this.getSkill(6);
        this.changeAnimation({
            animation: "attack",
            loop: !1,
            flag: !0,
            callback: function() {
                t.model.removeBuffer(c.BufferType.执行), t.canMove() && t.resumeMove(!0), e.doMedical(Math.round(t.model.ATK * o.scale), 1), 
                t.gameView.appendSkeleton({
                    url: "buffer/技能加血/7011",
                    root: e.node,
                    pos: cc.Vec2.ZERO
                }).then(function(e) {
                    e && (e.setAnimation(0, "7011", !1), e.setCompleteListener(function() {
                        e.setCompleteListener(null), t.gameView.removeSkeleton(e.node);
                    }));
                });
            }
        });
    }, e.prototype.attackAngleOne = function() {
        var n = this;
        this.model.addBuffer(c.BufferType.执行), this.pauseMove();
        var e = this.getSkill(7);
        this.changeAnimation({
            animation: "attack4",
            loop: !1,
            callback: function() {
                n.checkTarget(n) ? n.changeAnimation({
                    animation: "attack1",
                    loop: !0,
                    callback: function() {
                        var t, o, i;
                        n && ((t = new c.default()).group = n.model.group, t.SPE = 300, t.MOV = 600, t.pow = 50, 
                        t.type = c.ArmType.正常, t.bullet = 63, t.ATK = Math.round(n.model.ATK * e.scale), 
                        o = l.G.getCirclePoints(1, cc.v2(0, 0), e.num, .5, 1080), i = 0, cc.tween(n.node).repeat(e.num, cc.tween().call(function() {
                            var e = n.gameView.getArm().getComponent(p.default);
                            e && (e.node.setParent(n.gameView.bulletLayout), e.node.setPosition(n.node.getPosition().add(o[i % o.length].mul(20))), 
                            e.init(n, t, o[i % o.length].mul(2), n.node.getPosition().add(o[i % o.length].mul(20)))), 
                            i++;
                        }).delay(.01)).call(function() {
                            n.model.removeBuffer(c.BufferType.执行), n.resumeMove(), n.attackEnd();
                        }).start());
                    }
                }) : (n.model.removeBuffer(c.BufferType.执行), n.resumeMove(), n.attackEnd());
            }
        });
    }, e.prototype.attackAngleTwo = function() {}, e.prototype.attackAngleThree = function() {}, 
    e.prototype.sleep = function() {
        this.unscheduleAllCallbacks(), this.skill = null, this.target = null, this.isStart = !1, 
        this.pauseMove(!0), this._moveSpeed = 0, this.model.buffers.clear(), this.model.addBuffer(c.BufferType.无敌), 
        this.topNode && this.topNode.active && (this.topNode.active = !1), this.skeleton.node.color = cc.Color.WHITE, 
        this.skeleton.node.setPosition(cc.v2(0, -20)), this.changeAnimation({
            animation: this.petIdx < 100 ? "fall" : "down",
            loop: !1,
            flag: !0
        });
    }, e.prototype.awake = function() {
        var t = this;
        this.checkTarget(this) && (this.unscheduleAllCallbacks(), this.isStart = !0, this.resumeMove(!0), 
        this.model.buffers.clear(), this.topNode && !this.topNode.active && (this.topNode.active = !0), 
        this.bar.fillRange = 1, this.checkPlayerDistance(), this.schedule(function() {
            var e;
            t.isStart && !t.isPlay && t.checkTarget(t.player) && (t.model.hasBuffer(c.BufferType.切割) || (t.canAttack() ? 0 < (e = t.findTargets()).length ? (t.target = e[0], 
            t.run(e[0])) : (t.target = null, t.run(t.player)) : t.run(t.player)));
        }, this.think));
    }, e.prototype.doHurt = function(e, t) {
        var o = this;
        this.checkTarget(this) && this.canHurt() && (this.checkHurt(e, t), this.model.isDead() ? this.die() : (this.canMove() && t && (this.offect = t.mul(10 * e.pow)), 
        this.model.hasBuffer(c.BufferType.受伤) || (this.model.addBuffer(c.BufferType.受伤), 
        cc.tween(this.skeleton.node).repeat(2, cc.tween().call(function() {
            o.skeleton.node.color = cc.Color.GRAY;
        }).delay(.08).call(function() {
            o.skeleton.node.color = cc.Color.WHITE;
        }).delay(.08)).call(function() {
            o.model.removeBuffer(c.BufferType.受伤);
        }).start()), e.type == c.ArmType.闪电枪 ? this.doEle(function() {
            o.loadSkin(o.petIdx).then(function() {
                o.skeleton && o.skeleton.node.setPosition(cc.v2(0, -20)), o.model.hasBuffer(c.BufferType.切割) || o.attackEnd(0), 
                o.model.removeBuffer(c.BufferType.执行);
            });
        }) : e.type == c.ArmType.冰冻枪 ? this.doIce(function() {
            o.model.hasBuffer(c.BufferType.切割) || o.attackEnd(0), o.model.removeBuffer(c.BufferType.执行);
        }) : e.type == c.ArmType.切割 && this.doCut()));
    }, e.prototype.checkHurt = function(e, t) {
        this.model.openid == GA.Info.openId && (e.ATK = Math.round(e.ATK * (1 - f.GC.petbuffer / 100))), 
        o.prototype.checkHurt.call(this, e, t), this.model.openid == GA.Info.openId && (h.default.getInstance().getRealData().hp = Math.ceil(this.model.HP));
    }, e.prototype.doMedical = function(e, t) {
        o.prototype.doMedical.call(this, e, t = void 0 === t ? 0 : t), this.model.openid == GA.Info.openId && (h.default.getInstance().getRealData().hp = Math.ceil(this.model.HP));
    }, e.prototype.die = function() {
        var e = this;
        g.GD.isEffect && d.default.getInstance().playAudio("击杀"), this.unscheduleAllCallbacks(), 
        cc.Tween.stopAllByTarget(this.node), cc.Tween.stopAllByTarget(this.skeleton.node), 
        this.skill = null, this.target = null, this.pauseMove(!0), this.model.buffers.clear(), 
        this._moveSpeed = 0, this.topNode && this.topNode.active && (this.topNode.active = !1), 
        this.skeleton && this.skeleton.node.active ? (this.skeleton.unscheduleAllCallbacks(), 
        this.skeleton.clearTracks(), this.loadSkin(this.petIdx).then(function() {
            e.skeleton && (e.skeleton.node.color = cc.Color.WHITE, e.skeleton.node.setPosition(cc.v2(0, -20)), 
            e.changeAnimation({
                animation: e.petIdx < 100 ? "fall" : "down",
                loop: !1,
                flag: !0,
                callback: function() {
                    e.petIdx < 100 ? e.changeAnimation({
                        animation: "entrance",
                        loop: !1,
                        callback: function() {
                            e.node.active = !1;
                        }
                    }) : e.node.active = !1;
                }
            }));
        })) : this.node && (this.node.active = !1);
    }, e.prototype.entrance = function() {
        var e = this;
        !this.isPlay && 80 < this.player.node.position.sub(this.node.position).mag() && (this.model.addBuffer(c.BufferType.执行), 
        this.pauseMove(), this.changeAnimation({
            animation: "entrance",
            loop: !1,
            callback: function() {
                e.model.removeBuffer(c.BufferType.无敌), e.model.removeBuffer(c.BufferType.执行), e.canMove() && e.resumeMove();
            }
        }), this.node.position = this.player.node.position, this.node.setPosition(this.check(this.node.getPosition().add(cc.v2(60, 0)))));
    }, e.prototype.findPath = function(e) {
        var t = this.node.getPosition(), o = e.node.getPosition(), i = this.gameView.astar.getGird(t), e = this.gameView.astar.getGird(o);
        this.gameView.astar.retrieve(this.getRect(t, o, 40)).some(function(e) {
            return cc.Intersection.lineRect(t, o, e.node.getBoundingBox());
        }) ? (cc.log("findPath"), this.path = this.gameView.astar.findPath(i, e), this.gameView.astar.floyd(this.path)) : this.path = [ e, i ], 
        this.findTime = Date.now();
    }, e.prototype.findTargets = function() {
        var o = this;
        return 1 == this.config.type ? this.gameView.targets.filter(function(e) {
            return o.checkTarget(e) && e.model.HP != e.model.MAX_HP && e.model.group == o.model.group && e.node.position.sub(o.player.node.position).mag() < 900;
        }).sort(function(e, t) {
            return e.model.HP - t.model.HP;
        }) : this.gameView.targets.filter(function(e) {
            return o.checkTarget(e) && e.canHurt() && e.canFinded() && e.model.group != o.model.group && e.node.position.sub(o.player.node.position).mag() < 900;
        }).sort(function(e, t) {
            return e.node.position.sub(o.node.position).mag() - t.node.position.sub(o.node.position).mag();
        });
    }, e.prototype.checkDistance = function(e, t) {
        return void 0 === t && (t = 240), !!this.checkTarget(e) && e.node.position.sub(this.node.position).mag() < t;
    }, e.prototype.checkPlayerDistance = function(e) {
        if (void 0 === e && (e = 120), !this.checkTarget(this.player)) return !0;
        var t = this.player.node.position.sub(this.node.position).mag();
        if (900 < t) this.entrance(); else if (t < e) return this.pauseMove(), !0;
        return !1;
    }, e.prototype.getSkillIdx = function() {
        var t = this, o = 0, i = [], e = this.config.skills.filter(function(e) {
            return e.form <= t.form;
        });
        e.forEach(function(e) {
            o += e.weight;
        }), e.forEach(function(e) {
            0 < i.length ? i.push(i[i.length - 1] + e.weight / o) : i.push(e.weight / o);
        });
        for (var n = Math.random(), a = 0; a < i.length - 1 && i[a] < n; ) a++;
        return e[a].id;
    }, e.prototype.getSkill = function(e) {
        return this.skill || (this.skill = l.G.getPetSkill(e, 0 < this.config.skills.length ? this.config.skills[0].id : 0)), 
        Object.assign({}, this.skill);
    }, e.prototype.showLabel = function(e) {
        e && (5 < e.length ? this.label.string = e.substring(0, 5) + "... 的宠物" : this.label.string = e + " 的宠物"), 
        this.label.node.active = !0;
    }, e.prototype.updateDir = function(e) {
        void 0 === e && (e = this.moveDir), this.skeleton && (0 < e.x ? this.skeleton.node.scaleX = -this.scale : e.x < 0 && (this.skeleton.node.scaleX = this.scale));
    }, e.prototype.update = function(e) {
        var t, o, i = this;
        if (this.checkTarget(this)) {
            if (this.isStart) {
                if (this.model.updateBuffer(e), this.model.hasBuffer(c.BufferType.隐藏中) ? this.model.group == this.gameView.curPlayer.model.group ? (this.node.opacity = 150, 
                this.topNode.opacity = 150, this.bottomNode.opacity = 150) : 0 < (o = this.gameView.targets.filter(function(e) {
                    return e.model.group == i.gameView.curPlayer.model.group;
                }).filter(function(e) {
                    return e.checkVisual(i.node.getPosition());
                })).length ? (this.model.addBuffer(c.BufferType.暴露中, 3), this.node.opacity = 150, 
                this.topNode.opacity = 150, this.bottomNode.opacity = 150, o.forEach(function(e) {
                    return e.model.addBuffer(c.BufferType.暴露中, 3);
                })) : (this.node.opacity = 0, this.topNode.opacity = 0, this.bottomNode.opacity = 0) : (this.node.opacity = 255, 
                this.topNode.opacity = 255, this.bottomNode.opacity = 255), this.gameView.checkVisual(this.node.getPosition()), 
                this.canMove() && !this.isPlay) {
                    switch (this.model.hasBuffer(c.BufferType.切割) ? (this.checkTarget(this.target) || (this.target = null, 
                    0 < (t = this.findTargets()).length && (this.target = t[0])), this.target ? (this.moveDir = this.target.node.getPosition().sub(this.node.getPosition()).normalizeSelf(), 
                    80 < this.target.node.position.sub(this.node.position).mag() ? this._speedType = r.default.SpeedType.FAST : this.pauseMove(), 
                    this.petIdx < 100 && this.changeAnimation({
                        animation: "attack4",
                        loop: !0,
                        callback: function() {
                            i.skeleton.timeScale = 2;
                        }
                    })) : this.pauseMove()) : this.canAttack() && (this.checkTarget(this.target) ? (this.model.removeBuffer(c.BufferType.停顿), 
                    this.skill || (this.skill = l.G.getPetSkill(this.getSkillIdx(), this.petIdx < 100 ? 0 : 3), 
                    this.model.openid == GA.Info.openId && cc.log("宠物技能", this.skill)), (o = this.checkDistance(this.target, this.skill.range)) && this.attack()) : (this.target = null, 
                    this.checkPlayerDistance() ? this.model.addBuffer(c.BufferType.停顿) : this.model.removeBuffer(c.BufferType.停顿))), 
                    this._speedType) {
                      case r.default.SpeedType.STOP:
                        this._moveSpeed = 0, this.model.hasBuffer(c.BufferType.切割) || this.changeAnimation({
                            animation: "move2",
                            loop: !0
                        });
                        break;

                      case r.default.SpeedType.NORMAL:
                        this._moveSpeed = 300, this.model.hasBuffer(c.BufferType.切割) || this.changeAnimation({
                            animation: "move",
                            loop: !0
                        });
                        break;

                      case r.default.SpeedType.FAST:
                        this._moveSpeed = 400, this.model.hasBuffer(c.BufferType.切割) || this.changeAnimation({
                            animation: "move",
                            loop: !0
                        });
                    }
                    1 < this.offect.mag() ? this.offect = this.offect.mul(.9) : this.offect = cc.Vec2.ZERO, 
                    this.move(e), this.updateDir();
                }
                this.model.hasBuffer(c.BufferType.冷却) && (this.bar.fillRange < 1 ? this.bar.fillRange += e / this.IDLE : this.bar.fillRange = 1);
            }
            this.topNode && this.topNode.active && this.topNode.setPosition(this.node.getPosition()), 
            this.bottomNode && this.bottomNode.active && this.bottomNode.setPosition(this.node.getPosition());
        }
    }, a([ w(cc.Sprite) ], e.prototype, "bar", void 0), a([ w(cc.Label) ], e.prototype, "label", void 0), 
    n = a([ v ], e);
}(s.default);

n.default = b;